package com.ocom.xfrecode.controller;

import cn.hutool.core.convert.Convert;
import com.ocom.common.constant.RecodeUrl;
import com.ocom.common.entity.mongo.EntityDeviceHistoryPo;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.xfrecode.mongo.po.EntityDeviceHistory;
import com.ocom.xfrecode.mongo.service.DeviceHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DeviceHistoryController {
    @Autowired
    private DeviceHistoryService deviceHistoryService;

    @PostMapping(RecodeUrl.URL_saveDeviceHistory)
    public Result saveDeviceHistory(@RequestBody EntityDeviceHistoryPo deviceHistoryPo){
        EntityDeviceHistory entityDeviceHistory = Convert.convert(EntityDeviceHistory.class,deviceHistoryPo);
        return ResultUtil.success(this.deviceHistoryService.save(entityDeviceHistory));
    }
}
